﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Structure.Interfaces;
using Storage;
using Structure.Objects;

namespace Command
{
    internal class Command:iCommand
    {
        private iStorage Storage;

        private static readonly Command instance = new Command();

        public static Command Instance ()
        {
            return instance; 
        }

        protected Command()
        {
            Storage = BuildDBAccess.Build();
        }

        public DataTable ProjectList()
        {
            return Storage.ProjectList();
        }

        public void AddProject(Project p)
        {
            Storage.AddProject(p); 
        }

        public void DeleteProject(string id_project)
        {
            Storage.DeleteProject(id_project);
        }

        public DataTable SelectProject(int id_project)
        {
            return Storage.SelectProject(id_project);
        }

        public void UpdateProject(string id_project, Project p)
        {
            Storage.UpdateProject(id_project, p);
        }

        public Project GetProject(string id_project)
        {
            return Storage.GetProject(id_project);
        }   

        public DataTable TaskList()
        {
            return Storage.TaskList();
        }       

        public DataTable SelectTask(int id_task)
        {
            return Storage.SelectTask(id_task);
        }

        public void AddTask(Task t)
        {
            Storage.AddTask(t);
        }

        public void DeleteTask(string id_task)
        {
            Storage.DeleteTask(id_task);
        }

        public void UpdateTask(string id_task, Task t)
        {
            Storage.UpdateTask(id_task, t);
        }

        public Task GetTask(string id_task)
        {
            return Storage.GetTask(id_task);
        }   
        public void AddUser(User u)
        {
            Storage.AddUser(u);
        }

        public void DeleteUser(string index)
        {
            Storage.DeleteUser(index);
        }

        public DataTable UserList()
        {
            return Storage.UserList();
        }

        public void AddUserInProject(string id_user, string id_project)
        {
            Storage.AddUserInProject(id_user, id_project);
        }

        public void DeleteUserFromProject(string id_user, string id_project)
        {
            Storage.DeleteUserFromProject(id_user, id_project);
        }

        public DataTable GetAllUsersInProjects(string id_project)
        {
            return Storage.GetAllUsersInProjects(id_project);
        }

        public string Login(string pLogin, string pPass, ref string pFio)
        {
            return Storage.Login(pLogin, pPass, ref pFio);
        }

        public DataTable StatusList()
        {
            return Storage.StatusList();
        }
    }
}
